Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
Getting status of 400 - {"error":"invalid_grant"} On Authentication

I created my own website (www.luig.us). I create a basic IDE for SQL server to teach kids SQL, DML only.

It requires the user to enter an username and password at the beginning to get an token to use the service.

On local, everything works fine, but when I put it on my site, hosted by go-daddy, I will get the same message every time and I don't have a clue why.

{"error":"invalid_grant"}

This is my java script code - look for Authorize. Any help is appreciated. I followed this article closely https://www.c-sharpcorner.com/UploadFile/736ca4/token-based-authentication-in-web-api-2/



function Authorize() {
    let bearer = "Basic Q01JUzMwOERTMzA4OndlYkFQSQ=="
    var email = document.getElementById("email").value;
    var password = document.getElementById("password").value;
    var userNameAndPasswordFilled = (email != "" && password != "");
    if (!userNameAndPasswordFilled) {
        $("#formError").show('fast');
    }
    else {
        var bodyOfRequest = {
            grant_type: "password",
            username: email,
            password: password
        };
        $.ajax({
            type: "POST",
            url: uriManager.access,
            beforeSend: function (request) {
                request.setRequestHeader("Authorization", bearer);
            },
            data: bodyOfRequest,
            success: function (response) {
                sessionStorage.setItem(programKeyWords.BearerToken, response.access_token);
                $('#LogonModal').modal('hide');
            },
            error: function (response) {
                $("#formError").show('fast');
            }
        });
    }
}


over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I can't say much without more information but first thing I would check is if you actually have users in your database (or whatever oauth you're using). The error you're getting can likely be caused if you don't actually have a user with that username and password in your oauth database.

The endpoint you're using for uriManager.access is where you have to check if that user actually exists.

over 4 years ago · Santiago Trujillo Relatório

0

The problem wasn't with the code. The problem was with:

  1. The connection string. It was not correct.
  2. I was encrypting the username and password and it wasn't matching correctly because of special characters

What I did to fix it.

  1. fixed the connection string
  2. fixed the algorithm to store a hash instead of string.
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda